@echo off
chcp 65001 >nul
echo Getting ngrok tunnel addresses...
echo.

REM Check if ngrok is running
netstat -an | findstr :4040 >nul
if errorlevel 1 (
    echo Error: ngrok is not running!
    echo Please run "start-backend-tunnel.cmd" or "start-frontend-tunnel.cmd" first
    pause
    exit /b 1
)

echo Getting tunnel information...
echo.

REM Use PowerShell to get tunnel information
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:4040/api/tunnels' -UseBasicParsing; $tunnels = $response.Content | ConvertFrom-Json; foreach($tunnel in $tunnels.tunnels) { Write-Host 'Tunnel Name:' $tunnel.name; Write-Host 'Public URL:' $tunnel.public_url; Write-Host 'Protocol:' $tunnel.proto; Write-Host 'Local Address:' $tunnel.config.addr; Write-Host '---'; } } catch { Write-Host 'Failed to get tunnel info: ' $_.Exception.Message }"

echo.
echo You can also visit http://localhost:4040 to view the ngrok management interface
echo.

pause
